//package com.yunhe.device.controller.base;
//
//import com.yunhe.device.domain.base.PointDataType;
//import com.yunhe.device.domain.base.PointMeasureType;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.DatabaseProcessException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.base.PointDataTypeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Optional;
//
///**
// * 点号数据类型Controller
// * @author liuronglei
// */
//@Api(value = "pointDataType", description = "点号数据类型", tags = {"Base_PointDataType"})
//@RestController
//@RequestMapping("/types/pointData")
//public class PointDataTypeController {
//    @Autowired
//    private PointDataTypeService pointDataTypeService;
//
//    /**
//     * 新增点号数据类型
//     * @param pointDataType 点号数据类型对象
//     */
//    @ApiOperation("新增点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path")
//    })
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody PointDataType pointDataType)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        PointDataType newPointDataType = pointDataTypeService.createPointDataType(pointDataType);
//        return new ResponseEntity<>(new ResultObject<>(newPointDataType), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增点号数据类型
//     * @param domainList 点号数据类型对象列表
//     */
//    @ApiOperation("批量新增点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path")
//    })
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DomainList<PointDataType> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Iterable<PointDataType> results = pointDataTypeService.createPointDataType(domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除点号数据类型
//     * @param id 点号数据类型ID
//     */
//    @ApiOperation("根据ID删除点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "点号数据类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        pointDataTypeService.deletePointDataType(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新点号数据类型
//     * @param id 点号数据类型ID
//     * @param pointDataType 点号数据类型对象
//     */
//    @ApiOperation("更新点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "点号数据类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody PointDataType pointDataType)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        pointDataType.setId(id);
//        PointDataType newPointDataType = pointDataTypeService.updatePointDataType(pointDataType);
//        return new ResponseEntity<>(new ResultObject<>(newPointDataType), HttpStatus.OK);
//    }
//
//    /**
//     * 更新点号数据类型
//     * @param id 点号数据类型ID
//     * @param code 点号数据类型代码
//     * @param name 点号数据类型编号
//     * @param title 点号数据类型名称
//     * @param sn 排序序号
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "点号数据类型ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "点号数据类型编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "点号数据类型名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "sn", value = "排序序号", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "boolean", paramType = "query"),
//            @ApiImplicitParam(name = "unit", value = "数据单位", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title,
//            @RequestParam("sn") Optional<Long> sn,
//            @RequestParam("activity") Optional<Boolean> activity,
//            @RequestParam("unit") Optional<String> unit)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        PointDataType newPointDataType = pointDataTypeService.updatePointDataType(id, code.orElse(null), name.orElse(null), title.orElse(null), sn.orElse(null), activity.orElse(null), unit.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newPointDataType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据点号数据类型ID获得点号数据类型
//     * @param id 点号数据类型ID
//     */
//    @ApiOperation("根据点号数据类型ID获得点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "string", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "点号数据类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        PointDataType pointDataType = pointDataTypeService.findByPointDataTypeId(id);
//        return new ResponseEntity<>(new ResultObject<>(pointDataType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得点号数据类型列表
//     */
//    @ApiOperation("根据条件获得点号数据类型列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<PointDataType> results = pointDataTypeService.findPointDataTypes();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 绑定四遥类型（根据代码）
//     * @param code
//     * @param pointMeasureTypeCode
//     */
//    @ApiOperation("绑定四遥类型（根据代码）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "pointMeasureTypeCode", value = "四遥类型代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/pointMeasureTypes/{pointMeasureTypeCode}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindPointMeasureTypeByCode(@PathVariable("code") Long code,
//                                                                   @PathVariable("pointMeasureTypeCode") Long pointMeasureTypeCode)
//            throws DatabaseProcessException {
//        pointDataTypeService.bindPointMeasureTypeByCode(code, pointMeasureTypeCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 解绑四遥类型（根据代码）
//     * @param code
//     * @param pointMeasureTypeCode
//     */
//    @ApiOperation("解绑四遥类型（根据代码）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "pointMeasureTypeCode", value = "四遥类型代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/pointMeasureTypes/{pointMeasureTypeCode}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindPointMeasureTypeByCode(
//            @PathVariable("code") Long code,
//            @PathVariable("pointMeasureTypeCode") Long pointMeasureTypeCode)
//            throws DatabaseProcessException {
//        pointDataTypeService.unbindPointMeasureTypeByCode(code, pointMeasureTypeCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新四遥类型（根据代码）
//     * @param code 点号数据类型代码
//     * @param pointMeasureTypeCodes 四遥类型代码
//     */
//    @ApiOperation("更新四遥类型（根据代码）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点表代码", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "pointMeasureTypeCodes", value = "四遥类型代码（以逗号间隔）", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/byCode/{code}/pointMeasureTypes", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updatePointDataTypeByCode(
//            @PathVariable("code") Long code,
//            @RequestParam("pointMeasureTypeCodes") List<Long> pointMeasureTypeCodes)
//            throws DatabaseProcessException {
//        pointDataTypeService.updatePointMeasureTypeByCode(code, pointMeasureTypeCodes);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新四遥类型（根据代码）
//     * @param id ID
//     * @param analogStatusId 点表状态ID
//     */
//    @ApiOperation("更新点表状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "analogStatusId", value = "点表状态ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/analogStatus", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateAnalogStatus(
//            @PathVariable("id") Long id,
//            @RequestParam("analogStatusId") Long analogStatusId) {
//        pointDataTypeService.updateAnalogStatus(id, analogStatusId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取绑定的四遥类型（根据代码）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点表代码", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/pointMeasureTypes", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getPointMeasureTypeByCode(
//            @PathVariable("code") Long code) {
//        Iterable<PointMeasureType> results = pointDataTypeService.getPointMeasureTypeByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 根据代码获得点号数据类型
//     * @param code 代码
//     */
//    @ApiOperation("根据代码获得点号数据类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(
//            @PathVariable("code") Long code) {
//        PointDataType pointDataType = pointDataTypeService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(pointDataType), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据代码绑定点号状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "analogStatusCode", value = "点号状态代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/byAnalogStatusCode/{analogStatusCode}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindAnalogStatusByCode(
//            @PathVariable("code") Long code,
//            @PathVariable("analogStatusCode") Long analogStatusCode) {
//        pointDataTypeService.bindAnalogStatusByCode(code, analogStatusCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据代码解绑点号状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "analogStatusCode", value = "点号状态代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/byAnalogStatusCode/{analogStatusCode}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindAnalogStatusByCode(
//            @PathVariable("code") Long code,
//            @PathVariable("analogStatusCode") Long analogStatusCode) {
//        pointDataTypeService.unbindAnalogStatusByCode(code, analogStatusCode);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据代码获取数据存储频率")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "点号数据类型代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}/frequency", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getFrequencyByCode(
//            @PathVariable("code") Long code) {
//        Long result = pointDataTypeService.getFrequencyByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//}